package org.example;

import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * ClassName: WuDaAspect
 * Package: org.example
 * Description:
 *
 * @Author wanghao
 * @Create 2024-07-08 9:59
 * @Version 1.0
 */
/*
 * @Component: 表明当前切面类必须纳入ioc容器
 * @Aspect: 表明当前类是一个切面类
 */
//@Component
@Aspect
// 演示增强执行的顺序问题
// 从spring5.3.x开始，执行顺序是：@Before -- @AfterReturning or @AfterThrowing -- @After
public class WuDaAspect2 {

    @Before("execution(* *Bing(..))")
    public void song() {
        System.out.println("1.送大麦茶...");
    }

    @AfterReturning("execution(* *Bing(..))")
    public void song2() {

        System.out.println("2.送绿茶...");
    }

    @AfterThrowing("execution(* *Bing(..))")
    public void song3() {

        System.out.println("3.送茉莉茶...");
    }

    @After("execution(* *Bing(..))")
    public void song4() {
        System.out.println("4.送冰红茶...");
    }
}
